﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="UserManagement.aspx.cs" Inherits="WebClient.AdministrativeTools.UserManagement" %>

<%@ MasterType VirtualPath="~/Site.master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <h2>
        User Management
    </h2>

    <asp:UpdatePanel ID="UpdatePanel" UpdateMode="Conditional" runat="server">
        <Triggers>
            <asp:PostBackTrigger ControlID="EditUserButton" />
            <asp:PostBackTrigger ControlID="UserAccounts" />
        </Triggers>
        <ContentTemplate>
            <asp:Panel ID="EditUserPanel" runat="server" Visible="false">
            <asp:LinkButton ID="LinkButton1" runat="server" 
            OnClick="ViewCurrentUsers_Click">View Current Users</asp:LinkButton>
                <div class="accountInfo">
                    <fieldset class="register">
                        <legend>Edit User Information</legend>
                        <p>
                            <asp:Label ID="UserIDLabel" runat="server" >Unique UserID:</asp:Label>
                        </p>
                        <p>
                            <asp:Label ID="EditNetIDLabel" runat="server" AssociatedControlID="EditNetID">Edit NetID:</asp:Label>
                            <asp:TextBox ID="EditNetID" runat="server" ReadOnly="true" CssClass="textEntry"></asp:TextBox>
                        </p>
                        <p>
                            <asp:Label ID="EditUserPasswordLabel" runat="server" AssociatedControlID="EditUserPassword">Edit Password:</asp:Label>
                            <asp:TextBox ID="EditUserPassword" runat="server" CssClass="textEntry"></asp:TextBox>
                        </p>
                        <p>
                            <asp:Label ID="EditUserNameLabel" runat="server" AssociatedControlID="EditUserName">Edit Name:</asp:Label>
                            <asp:TextBox ID="EditUserName" runat="server" CssClass="textEntry"></asp:TextBox>
                        </p>
                        <p>
                            <asp:Label ID="EditUserUniversityIDLabel" runat="server" AssociatedControlID="EditUserUniversityID">Edit University ID:</asp:Label>
                            <asp:TextBox ID="EditUserUniversityID" runat="server" CssClass="textEntry"></asp:TextBox>
                        </p>
                        <p>
                            <asp:Label ID="EditEmailLabel" runat="server" AssociatedControlID="EditEmail">Edit E-mail:</asp:Label>
                            <asp:TextBox ID="EditEmail" runat="server" CssClass="textEntry"></asp:TextBox>
                        </p>
                        <p>
                            <asp:CheckBox ID="PayrollEditUser" runat="server" Text="Payroll Permissions" /> 
                            <asp:CheckBox ID="AdminEditUser" runat="server" Text="Admin Permissions" />
                        </p>
                    </fieldset>
                    <p class="submitButton">
                        <asp:Button ID="EditUserButton" runat="server" Text="Edit User" ValidationGroup="RegisterUserValidationGroup"
                            OnClick="EditUserButton_Click" />
                    </p>
            </asp:Panel>
            <asp:Panel ID="ViewUsersPanel" runat="server" Visible="true">
                <h3>
                    USER Search:
                </h3>
                <asp:TextBox ID="QueryNetID" runat="server"></asp:TextBox>
                <asp:Button ID="GetUserButton" runat="server" Text="Select User" OnClick="GetUserButton_Click" />
                <h3>
                    Currently registered users:
                </h3>
                <p>
                    <asp:LinkButton ID="GetUsersButton" runat="server" 
                        onclick="GetUsersButton_Click">Get Users</asp:LinkButton>
                     &nbsp;( Warning : This operation may take time)
                </p>
                <asp:GridView ID="UserAccounts" runat="server" Style="text-align: center" 
                    AutoGenerateColumns="False" onrowcommand="UserAccounts_RowCommand" 
                    onrowediting="UserAccounts_RowEditing" >
                    <Columns>
                        <asp:BoundField HeaderText="NetID" DataField="NetID" ReadOnly="True" />
                        <asp:BoundField HeaderText="UniversityID" DataField="UniversityID" 
                            ReadOnly="True" />
                        <asp:BoundField HeaderText="Email" DataField="Email" ReadOnly="True" />
                        <asp:BoundField HeaderText="Full Name" DataField="FullName" ReadOnly="True" />
                        <asp:BoundField DataField="Password" HeaderText="Password" ReadOnly="True" 
                            Visible="False" />
                        <asp:ButtonField CommandName="Edit" HeaderText="Edit User" Text="Edit" />
                    </Columns>
                </asp:GridView>
                <asp:LinkButton ID="CreateNewUserButton" runat="server" Text="Create New" OnClick="AddUserButton_Click" />
            </asp:Panel>
            <asp:Panel ID="CreateNewUser" runat="server" Visible="false">
                <h3>
                    Create new User:
                </h3>
                <asp:LinkButton ID="ViewCurrentUsers" runat="server" OnClick="ViewCurrentUsers_Click">View Current Users</asp:LinkButton>
                <div class="accountInfo">
                    <fieldset class="register">
                        <legend>New User Information</legend>
                        <p>
                            <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">NetID:</asp:Label>
                            <asp:TextBox ID="UserName" runat="server" CssClass="textEntry"></asp:TextBox>
                        </p>
                        <p>
                            <asp:Label ID="FirstNameLabel" runat="server" AssociatedControlID="FirstName">First Name:</asp:Label>
                            <asp:TextBox ID="FirstName" runat="server" CssClass="textEntry"></asp:TextBox>
                            <asp:Label ID="LastNameLabel" runat="server" AssociatedControlID="LastName">Last Name:</asp:Label>
                            <asp:TextBox ID="LastName" runat="server" CssClass="textEntry"></asp:TextBox>
                        </p>
                        <p>
                            <asp:Label ID="UniversityIDLabel" runat="server" AssociatedControlID="UniversityID">University ID:</asp:Label>
                            <asp:TextBox ID="UniversityID" runat="server" CssClass="textEntry"></asp:TextBox>
                        </p>
                        <p>
                            <asp:Label ID="EmailLabel" runat="server" AssociatedControlID="Email">E-mail:</asp:Label>
                            <asp:TextBox ID="Email" runat="server" CssClass="textEntry"></asp:TextBox>
                        </p>
                        <p>
                            
                            <asp:CheckBox ID="NewUserPayroll" runat="server" Text="Payroll Permissions" /> 
                            <asp:CheckBox ID="NewUserAdmin" runat="server" Text="Admin Permissions" />
                            
                        </p>
                    </fieldset>
                    <p class="submitButton">
                        <asp:Button ID="CreateUserButton" runat="server" CommandName="MoveNext" Text="Create User"
                            ValidationGroup="RegisterUserValidationGroup" OnClick="CreateUserButton_Click" />
                    </p>
            </asp:Panel>
            <div id ="errorPanel">
                    <asp:Panel ID="ErrorPanel" runat="server" Visible="False">
                    <asp:TextBox ID="ErrorText" runat="server" Height="155px" Width="328px" 
                            ForeColor="White" TextMode="MultiLine" BackColor="Black"></asp:TextBox>
                        <br />
                    <asp:Button ID="ErrorClose" runat="server" Text="Close" onclick="ErrorClose_Click"></asp:Button>
                    </asp:Panel>
                </div>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
